package com.sunnada.poi.controller;

import com.sunnada.poi.bean.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;
import java.util.*;

/**
 * @program: poiextended
 * @description: 导出测试
 * @author: 李瑞益
 * @create: 2018-11-05 19:19
 **/
@Controller
public class ExcelTest {

    @RequestMapping("/export")
    @ResponseBody
    public String export(HttpServletResponse response){
        List<User> list = new ArrayList<>();
        User user1 = new User();
        User user2 = new User();
        User user3 = new User();
        User user4 = new User();

        user1.setId(1);
        user1.setAge(11);
        ;
        user1.setName("user1");
        user2.setId(2);
        user2.setAge(22);
        ;
        user2.setName("user2");
        user3.setId(3);
        user3.setAge(33);
        ;
        user3.setName("user3");
        user4.setId(4);
        user4.setAge(44);
        ;
        user4.setName("user4");
        list.add(user1);
        list.add(user2);
        list.add(user3);
        list.add(user4);

        String s = "123";
        String[] ss = s.split("/");
        System.out.print(Arrays.toString(ss));
        String[] title = new String[]{"id", "age", "name"};
        Map<String, String> headerName = new LinkedHashMap<>();
        headerName.put("id", "ID12323132123132");
        headerName.put("age", "年龄");
        headerName.put("name", "姓名");
        int i = 0;
        if(i == 0){}
//        ExportExcel2 e = new ExportExcel2();
//        e.exportToExcel(ExportExcel2.EXECEL_VERSION_03,"测试",list,headerName,new StyleBase2Test(),"D:\\ProgramData\\Gitee Pro\\poiextended\\src\\main\\resources/t.xls");
//                ExcelExportUtil.newInstance().exportToExcel(ExcelExportUtil.EXECEL_VERSION_03,"测试",list,headerName,new StyleBase(), response,"test");
        return "ok";
    }
}
